﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CartoGraphic
{
    public partial class StyleForm : Form
    {

        private Color bordercolor, fillcolor;
        private int penwidth;
        private bool isfill;

        public Color BorderColor
        {
            get { return bordercolor; }
            set { bordercolor = value; }
        }

        public Color FillColor
        {
            get { return fillcolor; }
            set { fillcolor = value; }
        }

        public int PenWidth
        {
            get { return penwidth; }
            set { penwidth = value; }
        }

        public bool IsFill
        {
            get { return isfill; }
            set { isfill = value; }
        }
        public StyleForm()
        {
            InitializeComponent();
            if(bordercolor!=null)
            buttonBorderColor.BackColor = bordercolor;
            if(fillcolor!=null)
            buttonFillColor.BackColor = fillcolor;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        private void buttonBorderColor_Click(object sender, EventArgs e)
        {
            colorDialog1.Color = Color.FromArgb(255,255,255);
            colorDialog1.ShowDialog();
            bordercolor = colorDialog1.Color;
            buttonBorderColor.BackColor = bordercolor;
        }

        private void buttonFillColor_Click(object sender, EventArgs e)
        {
            colorDialog1.Color = Color.FromArgb(255, 255, 255);
            colorDialog1.ShowDialog();
            fillcolor = colorDialog1.Color;
            buttonFillColor.BackColor = fillcolor;
            if (fillcolor == Color.FromArgb(255, 255, 255))
                isfill = false;
        }

        private void StyleForm_Load(object sender, EventArgs e)
        {
            if (bordercolor != null)
                buttonBorderColor.BackColor = bordercolor;
            if (fillcolor != null)
                buttonFillColor.BackColor = fillcolor;
            if(PenWidth>0)
                trackBar1.Value = PenWidth;
            penwidthLabel.Text = PenWidth.ToString() + "像素";
        }

        private void trackBar1_Scroll(object sender, EventArgs e)
        {
            penwidth = trackBar1.Value;
            penwidthLabel.Text = PenWidth.ToString()+"像素";
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            buttonFillColor.Visible = true;
            isfill = true;
        }
    }
}
